package android.slc.appbase.utils;

import android.slc.appbase.config.ConstantsBase;
import android.slc.appbase.repository.local.sp.AppConfig;
import android.slc.box.commonlibrary.compat.SlcPathUtils;
import cn.hutool.core.io.FileUtil;

import java.io.File;
import java.io.IOException;

public class AppPathUtils extends SlcPathUtils {

    //*************************************  book  *************************//

    /**
     * 获取文章页面
     *
     * @return
     */
    public static String getTemplatesPath() {
        File bookPageTemp = FileUtil.mkdir(SlcPathUtils.createAppCacheFile("templates").getAbsolutePath());
        return bookPageTemp.getAbsolutePath();
    }

    /**
     * 隐藏文件
     *
     * @param filePath
     */
    public static void hideFile(String filePath) {
        if(!AppConfig.isIsRelease()){
            return;
        }
        try {
            Runtime.getRuntime().exec("attrib +s +h " + filePath);
        } catch (IOException e) {
            //e.printStackTrace();
        }
    }

    /**
     * 显示文件
     *
     * @param filePath
     */
    public static void showFile(String filePath) {
        if(!AppConfig.isIsRelease()){
            return;
        }
        try {
            Runtime.getRuntime().exec("attrib -s +h " + filePath);
        } catch (IOException e) {
            //e.printStackTrace();
        }
    }


    /**
     * 完全文件
     *
     * @param filePath
     */
    public static void fullShowFile(String filePath) {
        if(!AppConfig.isIsRelease()){
            return;
        }
        try {
            Runtime.getRuntime().exec("attrib -s -h " + filePath);
        } catch (IOException e) {
            //e.printStackTrace();
        }
    }
}
